#分段函数
import math
x=int(input())
if x>=-6 and x<0:
    y=abs(x)+5
elif x>=0 and x<3:
    y=math.factorial(x)
elif x>=3 and x<=6:
    y=x**(x-2)
else:
    y=0
print(y)